package com.hengpeng.itfin.persist;

import java.util.Date;
import java.util.List;

import com.hengpeng.common.persist.NestedSimplyDao;
import com.hengpeng.itfinbase.en.BorrowStatus;
import com.hengpeng.itfinbase.en.InputStatus;
import com.hengpeng.itfinbase.persist.BorrowInfo;

public interface BorrowInfoDao extends NestedSimplyDao<BorrowInfo> {
    /**
     * 释放额度
     * 
     * @param borrowInfoId
     * @param rasieMoney
     * @param raiseNum
     * @return
     */
    public int releaseBorrowMoney(Long borrowInfoId, Long rasieMoney, int raiseNum);

    /**
     * 释放额度并更新状态
     * 
     * @param borrowInfoId
     * @param rasieMoney
     * @param raiseNum
     * @param newStatus
     * @return
     */
    public int releaseBorrowMoneyStatus(Long borrowInfoId, Long rasieMoney, int raiseNum, BorrowStatus newStatus);

    /**
     * 标的开标
     * 
     * @return
     */
    public int borrowStartRaise(BorrowStatus newStatus, Date updateTime, BorrowStatus oldStatus, Date bidOpenTime);

    /**
     * <pre>
     * 更新所有数据
     * </pre>
     * 
     * @param infoList
     */
    public void updateList(List<BorrowInfo> infoList);

    /**
     * 截标
     * 
     * @param newStatus
     * @param updateTime
     * @param oldStatus
     * @param bidStopTime
     * @return
     */
    public int borrowEndRaise(BorrowStatus newStatus, Date updateTime, BorrowStatus oldStatus, Date bidStopTime);

    /**
     * <pre>
     * 获取标的
     * </pre>
     * 
     * @param id
     * @param status
     * @return
     */
    public BorrowInfo getBorrowInfo(Long id, BorrowStatus status);

    /**
     * <pre>
     * 通过主键锁表
     * </pre>
     * 
     * @param id
     * @return
     */
    public BorrowInfo lockInfo(Long id);

    /**
     * <pre>
     * 更新
     * </pre>
     * 
     * @param borrow
     */
    public void updateInfo(BorrowInfo borrow);

    /**
     * 更新标的录入状态
     * 
     * @param newStatus
     * @param updateTime
     * @param borrowInfoId
     * @param oldStatusWait
     * @param oldStatusFailed
     */
    public int updateInputStatus(InputStatus newStatus, Date updateTime, Long borrowInfoId, InputStatus oldStatusWait,
            InputStatus oldStatusFailed);

    /**
     * <pre>
     * 获取未录入标的信息到第三方支付的标的
     * </pre>
     * 
     * @return
     */
    public List<BorrowInfo> getUnAddBidList();

    /**
     * <pre>
     * 获取放款或者流标中的标的信息
     * </pre>
     * 
     * @return
     */
    public List<BorrowInfo> queryBorrowList(BorrowStatus status);

    /**
     * 占据额度
     * 
     * @param id
     * @param money
     * @return
     */
    public int updateRaiseMoney(Long id, Long money);

    public int updateStatus(Long id, BorrowStatus newStatus, BorrowStatus oldStatus, Date updatTime,
            Date repaymentedTime);
}
